package com.zwy.space.service;

import com.zwy.space.domain.Resource;
import com.zwy.space.mapper.ResourceMapper;
import com.zwy.space.queryVo.ResourceTypeVo;
import com.zwy.space.queryVo.ResourceVo;
import com.zwy.space.queryVo.admin.SearchResourceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ResourceService {

    @Autowired
    private ResourceMapper resourceMapper;

    public List<ResourceVo> findAllResource() {
        return resourceMapper.findAllResource();
    }

    public List<ResourceTypeVo> findAllTypes() {
        return resourceMapper.findAllTypes();
    }

    public List<ResourceVo> findResourceByType(int typeId) {
        return resourceMapper.findResourceByType(typeId);
    }

    public List<com.zwy.space.queryVo.admin.ResourceVo> findResource() {
        return  resourceMapper.findResource();
    }

    public List<com.zwy.space.queryVo.admin.ResourceVo> findResourcesBySerach(SearchResourceVo searchResource) {
        return resourceMapper.findResourcesBySerach(searchResource);
    }

    public int saveResource(Resource resource) {
        resource.setCreateTime(new Date());
        return  resourceMapper.saveResource(resource);
    }

    public Resource editResourceById(int resourceId) {
        return  resourceMapper.editResourceById(resourceId);
    }


    public int updateResource(com.zwy.space.queryVo.admin.ResourceVo resourceVo) {
        resourceVo.setCreateTime(new Date());
        return  resourceMapper.updateResource(resourceVo);
    }

    public void deleteResource(int id) {
        resourceMapper.deleteResource(id);
    }
}
